package com._520it.wms.query;

import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by dd on 2017/11/15.
 */
//分页条件
@Getter
@Setter
public class PageResult {
    private int currentPage;
    private int pageSize;

    private List<?> result;
    private int totalCount;

    private int prevPage;
    private int nextPage;
    private int totalPage;

    public PageResult() {
    }

    public PageResult(int currentPage,int pageSize) {
        this(currentPage, pageSize, new ArrayList<>(), 0);
    }

    public PageResult(int currentPage, int pageSize, List<?> result, int totalCount) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.result = result;
        this.totalCount = totalCount;


        this.prevPage = this.currentPage - 1 > 1 ? this.currentPage - 1 : 1;
        this.totalPage = this.totalCount % this.pageSize == 0 ?
                this.totalCount / this.pageSize : this.totalCount / this.pageSize + 1;
        this.nextPage = this.currentPage + 1 < this.totalPage ?
                this.currentPage + 1 : this.totalPage;
    }
}
